package com.sgb.jicai.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.jicai.R;
import com.sgb.jicai.base.JiCaiBaseApi;
import com.swgk.core.view.entity.VideoListEntity;
import com.swgk.core.base.api.ICallBack;
import com.sgb.jicai.view.fragment.CentralizedMiningFragment5;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.swgk.core.view.entity.MenuEntity;

public class CentralizedMining5Model extends ViewModel {

    private CentralizedMiningFragment5 fragment;

    int[] images = new int[]{
            R.drawable.jcdt, R.drawable.xfjc,R.drawable.cjjc,R.drawable.qyzx,R.drawable.jbjc,
            R.drawable.hzcg, R.drawable.wdjm,R.drawable.wdbj,R.drawable.jicai_home_jmjy,R.drawable.jicai_home_bjjy
//            R.drawable.jcsj
    };
     String[] name = new String[]{
            "集采大厅","需方发起","供方发起","企业专项","即报即采","汇集采购","我的加盟","我的报价","加盟机遇","报价机遇"
//             ,"集采锁价"
     };

    public List<MenuEntity> getMenuData() {
        List<MenuEntity> menuEntityList = new ArrayList<>();
        for (int i=0;i< images.length;i++){
            MenuEntity menuEntity = new MenuEntity();
            menuEntity.setImageResource(images[i]);
            menuEntity.setAppIcon(String.valueOf(images[i]));
            menuEntity.setName(name[i]);
            menuEntityList.add(menuEntity);
        }

        return menuEntityList;
    }

    public void getVideoList(String parentName, String name) {
        Map map =new HashMap<>();
        map.put("limit",10);
        map.put("page",1);
        map.put("parentName",parentName);
        map.put("name",name);
        DialogHelper.showProgressDialog(fragment.getContext(), null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        JiCaiBaseApi.getApi().getVodListByCondition(map).enqueue(new ICallBack<BaseEntity<VideoListEntity>>() {
            @Override
            public void onSuccess(BaseEntity<VideoListEntity> data) {
                DialogHelper.dismissProgressDialog();
                fragment.setVideoTypeList(data.getData());
            }
        });
    }

    public void setActivity(CentralizedMiningFragment5 fragment) {
        this.fragment = fragment;
    }
}
